package org.atlantis.netty.time;

import java.util.Date;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;

public class TimeClientHandler extends SimpleChannelHandler {

	@Override
	public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
		ChannelBuffer buf = (ChannelBuffer) e.getMessage();
		long currentTimeMills = buf.readInt() * 1000L;
		System.out.println(new Date(currentTimeMills));
		System.out.println(e.getChannel().getRemoteAddress());
		e.getChannel().close();
	}
}
